"""
A Browser object is used to set the browser properties like user-agent.

It has get and post methods, both returns an Html instance that can be used 
to browse the html. For more information about Tag objects (like Html)
please refer to html/tags.py
"""
from navigator.html.parser import Parser

from urllib2 import urlopen
import urllib

class Browser(object):
    
    def __init__(self, *args, **kwds):
        """
        >>> browser = Browser("http://www.google.com/")
        >>>
        """

    def get(self, url):
        u = urlopen(url)
        return Parser(u.read()).html

    def post(self, url, data):
        d = urllib.urlencode(data)
        u = urlopen(url, d)
        return Parser(u.read).html

def _test():
    import doctest
    doctest.testmod()

if __name__ == "__main__":
    _test()

